<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Testing Event Functions</title>
<link rel="stylesheet" type="text/css" href="test.css"/>
<style type="text/css">
</style>
<script type="text/javascript" src="../reg.js"></script>
<script type="text/javascript">
reg.importAll();

reg.postSetup(function(){
	var test = gebi('testadd');
	var mem = addEvent(test, 'click', function(e){
		rcn(this, 'unconfirmed');
		rcn(this, 'failed');
		acn(this, 'confirmed');
		this.innerHTML = 'addEvent() works';
	});
});

reg.postSetup(function(){
	var test = gebi('testcancel');
	var mem = addEvent(test, 'click', function(e){
		cancelBubble(e);
		rcn(this, 'unconfirmed');
		rcn(this, 'failed');
		acn(this, 'confirmed');
		this.innerHTML = 'cancelBubble() works';
	});
});

reg.click('#testcancel',function(e){
	rcn(this, 'confirmed');
	rcn(this, 'unconfirmed');
	acn(this, 'failed');
	this.innerHTML = 'cancelBubble() failed';
});

reg.click('#testtarget',function(e){
	var t = getTarget(e);
	if (matches(t, 'div#testtarget.test')) {
		rcn(this, 'failed');
		rcn(this, 'unconfirmed');
		acn(this, 'confirmed');
		this.innerHTML = 'getTarget() works';
	} else {
		rcn(this, 'unconfirmed');
		rcn(this, 'confirmed');
		acn(this, 'failed');
		this.innerHTML = 'getTarget() failed';
	}
});

reg.postSetup(function(){
	var el = gebi('testremove');
	var mem = addEvent(el, 'click', function(e){
		rcn(this, 'unconfirmed');
		rcn(this, 'confirmed');
		acn(this, 'failed');
		this.innerHTML = 'removeEvent() failed';
		cancelBubble(e);
	});
	removeEvent(mem);
});

reg.click('#testremove', function(){
	rcn(this, 'failed');
	rcn(this, 'unconfirmed');
	acn(this, 'confirmed');
	this.innerHTML = 'removeEvent() works';
});

reg.click('#testdefault a@href', function(){
	var div = this.parentNode;
	rcn(div, 'failed');
	rcn(div, 'unconfirmed');
	acn(div, 'confirmed');
	this.innerHTML = 'cancelDefault() works';
	return false;
});

</script>
</head>
<body>
<div id="pagewrap">
<p><a href="index.html">&laquo; back to index</a></p>
<h1>Testing Event Functions</h1>

<div id="testadd" class="test unconfirmed">
click to test addEvent()
</div>

<div id="testremove" class="test unconfirmed">
click to test removeEvent()
</div>

<div id="testcancel" class="test unconfirmed">
click to test cancelBubble()
</div>

<div id="testdefault" class="test unconfirmed">
<a href="http://www.google.com/">click to test cancelDefault()</a>
</div>

<div id="testtarget" class="test unconfirmed">
click to test getTarget()
</div>

</div>
</body>
</html>



